using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreManager : MonoBehaviour
{
    public static ScoreManager Instance { get; private set; }

    [SerializeField] Sprite[] sprites3000;
    [SerializeField] Sprite[] sprites5000;
    [SerializeField] Sprite[] sprites10000;

    private GameObject prefabScore;

    void Awake()
    {
        Instance = this;
        this.prefabScore = Resources.Load<GameObject>("Prefabs/Items/Score");
    }

    public void Show(Vector3 position, int score)
    {
        var scoreSpriteRenderer = Instantiate(this.prefabScore, position, Quaternion.identity).GetComponent<SpriteRenderer>();
        var index = 0;
        Sprite sprite = null;
        switch (score)
        {
            case 3000:
                index = Random.Range(0, this.sprites3000.Length);
                sprite = this.sprites3000[index];
                break;
            case 5000:
                index = Random.Range(0, this.sprites5000.Length);
                sprite = this.sprites5000[index];
                break;
            case 10000:
                index = Random.Range(0, this.sprites10000.Length);
                sprite = this.sprites10000[index];
                break;
        }
        scoreSpriteRenderer.sprite = sprite;
    }
}
